window.onload = function () {
    var top = document.getElementById("top_nav");
    var btnArr = top.getElementsByTagName("button");
    for (var i = 0; i < btnArr.length; i++) {
        btnArr[i].id = i;
        btnArr[i].onclick = function () {
        	$("#searchstyle").val(this.id);
            if (btnArr[this.id].getElementsByTagName("span")[0].className == "glyphicon glyphicon-chevron-down") {
                for (var i = 0; i < btnArr.length; i++) {
                    btnArr[i].getElementsByTagName("span")[0].className = "glyphicon glyphicon-chevron-down";
                }
                btnArr[this.id].getElementsByTagName("span")[0].className = "glyphicon glyphicon-chevron-up";
            }
            else btnArr[this.id].getElementsByTagName("span")[0].className = "glyphicon glyphicon-chevron-down";
        };
    }
    
};